package com.zhuoyue.biz.core.api.service;

import com.baomidou.mybatisplus.extension.service.IService;

import com.zhuoyue.biz.core.api.domain.AppUserDO;
import com.zhuoyue.biz.core.api.domain.AppUserHomeRelationDO;
import com.zhuoyue.common.dto.BaseResultDTO;


import java.util.List;

/**
 * @author wjming
 * @ClassName: AppUserService
 * @Description: 用户操作
 * @Date 2021/2/20 12:53
 */
public interface AppUserService extends IService<AppUserDO> {

    /**
     * APP用户注册
     *
     * @param user
     * @param organizationCode
     * @return
     * @throws Exception :MD5异常抛出
     */
    AppUserDO register(AppUserDO user, String organizationCode) throws Exception;


    /**
     * 根据账号和密码查询APP用户
     *
     * @param query
     * @return
     * @throws Exception :MD5加密异常抛出
     */
    AppUserDO getAppUserByAccountAndPassword(AppUserDO query) throws Exception;

    /**
     * 修改token
     *
     * @param appUser
     * @return
     */
    BaseResultDTO updateTokenById(AppUserDO appUser);

    /**
     * 通过用户ID清空
     *
     * @param query
     * @return
     */
    int updateClearByOpenId(AppUserDO query);

    /**
     * 通过用户ID修改
     *
     * @param query
     * @return
     */
    int updateOpenIdById(AppUserDO query);


    /**
     * 根据openid查询用户信息
     *
     * @param query
     * @return
     */
    AppUserDO getAppUserByOpenid(AppUserDO query);

    /**
     * 重置登录密码
     *
     * @param appUser
     * @return
     * @throws Exception MD5异常抛出
     */
    Boolean resetPassword(AppUserDO appUser) throws Exception;

    /**
     * 修改用户信息
     *
     * @param appUser
     * @return
     */
    Boolean modifyAppUserInfo(AppUserDO appUser);


    /**
     * 创建子账号
     *
     * @param appUserId
     * @param homeId
     * @param childAccount
     * @param organizationCode
     * @return
     */
    void createChildAccount(String appUserId, String homeId,
                            String childAccount, String organizationCode);

    /**
     * 删除子账号
     *
     * @param homeId
     * @param childAccount
     * @param organizationCode
     * @return
     */
    String removeChildAccount(String homeId, String childAccount, String organizationCode);

    /**
     * 查询家庭的子账号用户
     *
     * @param homeId
     * @return
     */
    List<AppUserDO> getChildUserList(String homeId);


    /**
     * 获得SourceId ，修改成除了手机号以外还需要组织id
     *
     * @param account
     * @param organizationCode
     * @return
     */
    AppUserDO getSourceTypeByAccount(String account, String organizationCode);


    /**
     * 设备转移
     *
     * @param transferAccount
     * @param query
     * @param organizationCode
     * @return
     */
    void updateAppuserId(String transferAccount, AppUserHomeRelationDO query, String organizationCode);


    /**
     * 获取主人的sourceId
     *
     * @param homeId
     * @return 1
     */
    AppUserDO getMasterSourceId(String homeId);


    /**
     * 查询App用户信息
     *
     * @param account
     * @param organizationCode
     * @return
     */
    AppUserDO accountReg(String account, String organizationCode);


}
